from appengine_django.models import BaseModel
from google.appengine.ext import db

# Create your models here.
'''
class Currency(db.Model):
	name = db.StringProperty(required=True)

class ExchangeRate(db.Model):
	date = db.DateProperty(required=True)
	rate = db.FloatProperty(required=True)	
	currency = db.ReferenceProperty(Currency)
'''	

class Fund(db.Model):
	name =  db.StringProperty(required=True) 
	dataSourceUrl = db.StringProperty() 
	currency = db.StringProperty()
	exchangeRate = db.FloatProperty()
	type = db.StringProperty(required=True, choices=set(["Once","Periodical"])) 
	startDate = db.DateProperty()	
	amount = db.FloatProperty() 
	surcharge = db.FloatProperty() 
	stopLoss = db.FloatProperty()
	stopProfit = db.FloatProperty() 
	comment = db.TextProperty() 
	buyNetValue = db.FloatProperty() 
	buyCount = db.FloatProperty()  
	lastUpdated = db.DateTimeProperty(auto_now_add=True)
	dateCreated = db.DateTimeProperty(auto_now=True)
	
	
class FundNetValue(db.Model):
	fund = db.ReferenceProperty(Fund) 
	netValue = db.FloatProperty(required=True) 
	date = db.DateProperty(required=True)
	lastUpdated = db.DateTimeProperty(auto_now_add=True)
	dateCreated = db.DateTimeProperty(auto_now=True)	